[id].vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. <template>
  2. <div>
  3. <!-- 页面头部 -->
  4. <HomePageHead></HomePageHead>
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 商圈详情 -->
  7. <div class="topicInfoBox">
  8. <div class="inner">
  9. <!-- 详情头部 -->
  10. <div class="infoHead">
  11. <div class="left">
  12. <div class="userInfo left">
  13. <el-badge value="楼主" class="item" type="warning">
  14. <img v-if='dataInfo.avatar' :src="dataInfo.avatar" alt="">
  15. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png'
  16. alt="">
  17. </el-badge>
  18. <span>{{ dataInfo.nickname }}</span>
  19. </div>
  20. <div class="headContent left">
  21. <h2>{{ dataInfo.title }}</h2>
  22. <p v-show="dataInfo.group_name">
  23. 群聊:
  24. <span>{{ dataInfo.group_name }}</span>
  25. <button @click="joinGroup">加入群聊</button>
  26. </p>
  27. </div>
  28. </div>
  29. <div class="right">
  30. <div class="one">
  31. <span v-for="item in typeList" :key="index">
  32. <span v-if="dataInfo.type == item.value" class="one">{{ item.label }}</span>
  33. </span>
  34. </div>
  35. <p>{{ dataInfo.updated_at }}</p>
  36. </div>
  37. </div>
  38. <!-- 详情页 文本+图片 -->
  39. <div class="infoContent" v-show="dataInfo.content">
  40. <div v-html="dataInfo.content"></div>
  41. </div>
  42. <div class="infoContent1" v-show="!dataInfo.content">
  43. <img src="http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Document_empty.png" alt="">
  44. <span>可以看看大家的互动哦~</span>
  45. </div>
  46. <!-- 详情页评论 -->
  47. <div class="comment">
  48. <h3>评论</h3>
  49. <div class="commentList" v-for="item in replyList" v-show="page_total != 0">
  50. <div class="left">
  51. <img v-if='item.avatar' :src="item.avatar" alt="">
  52. <img v-else src='http://img.bjzxtw.org.cn/master/bjzxtw/public/topic/Rectangle.png' alt="">
  53. <span class="name">{{ item.nickname }} : </span>
  54. </div>
  55. <div class="center">
  56. <span class="context">{{ item.content }}</span>
  57. </div>
  58. <div class="right">
  59. <span class="time">{{ item.created_at }}</span>
  60. <!-- <span>回复</span> -->
  61. </div>
  62. </div>
  63. <div class="comment_empty" v-show="page_total == 0">
  64. <img src="../../public/topic/message_empty.png" alt="">
  65. <span>暂无评论</span>
  66. </div>
  67. </div>
  68. <!-- 分页 -->
  69. <div class="paginationBox" v-show="page_total != 0">
  70. <el-pagination background layout="prev, pager, next" :total="page_total" prev-text="上一页"
  71. next-text="下一页" :default-page-size="pageSize" @change="changePage" />
  72. </div>
  73. </div>
  74. </div>
  75. <div class="message">
  76. <div class="inner">
  77. <input v-model="content" placeholder="快来回复吧~" type="text" class="messageInput">
  78. <button class="btn" @click="addReply">确定</button>
  79. </div>
  80. </div>
  81. <!-- 页面底部 -->
  82. <HomeFoot1></HomeFoot1>
  83. </div>
  84. </template>
  85. <script setup>
  86. //1.引用模块 start ---------------------------------------->
  87. //使用ref和reactive动态变量
  88. import { ref, reactive, onMounted } from 'vue'
  89. import { useRoute } from 'vue-router';
  90. //使用官方ssr请求模块
  91. import { useNuxtApp, useFetch } from '#app'
  92. //使用element-plus组件
  93. import { ElPagination, ElBadge, ElInput, ElMessage, ElMessageBox } from 'element-plus';
  94. // axios请求
  95. const nuxtApp = useNuxtApp();
  96. const axios = nuxtApp.$axios;
  97. const { $webUrl, $CwebUrl, $BwebUrl } = useNuxtApp()
  98. //1.引用模块 end ---------------------------------------->
  99. // 定义响应式数据
  100. const seoData = ref({
  101. title: '商圈',
  102. description: '默认描述',
  103. keywords: '默认关键词',
  104. image: 'https://example.com/default-image.jpg'
  105. });
  106. // 在 onMounted 钩子中获取数据
  107. onMounted(() => {
  108. seoData.value.title = '商圈';
  109. seoData.value.description = '默认描述';
  110. seoData.value.keywords = '默认关键词';
  111. })
  112. //2.页面数据 start ---------------------------------------->
  113. const dataInfo = ref({})
  114. const groupId = useState("groupId", () => '')
  115. const replyList = useState("replyList", () => []) //评论列表
  116. //分页
  117. const page = ref(1)
  118. const pageSize = ref(5)
  119. let page_total = ref(0)
  120. const content = ref('')
  121. //2.页面数据 end ---------------------------------------->
  122. //3.获取商圈详情 start ---------------------------------------->
  123. const route = useRoute();
  124. const id = route.params.id; // 获取传递的 id 参数
  125. //页码发生改变
  126. const changePage = (val) => {
  127. console.log(val);
  128. page.value = val
  129. getTopicReply()
  130. }
  131. // 商圈信息
  132. const getTopicInfo = () => {
  133. let data = new FormData()
  134. data.append('id', id)
  135. axios.post('chat/getTopicInfo', data).then(res => {
  136. console.log('商圈信息', res);
  137. dataInfo.value = res.data
  138. groupId.value = res.data.group_id
  139. console.log(groupId.value);
  140. })
  141. }
  142. // 回复商圈 列表
  143. const getTopicReply = () => {
  144. let data = new FormData()
  145. data.append('id', id)
  146. data.append('page', page.value)
  147. data.append('page_size', pageSize.value)
  148. axios.post('chat/getTopicReply', data).then(res => {
  149. console.log('回复商圈列表 ', res);
  150. replyList.value = res.data.data
  151. // page_total.value = res.data.total
  152. page_total.value = res.data.total
  153. console.log("replyList", replyList);
  154. })
  155. }
  156. //5.获取分类和状态 start ---------------------------------------->
  157. const listData = useState("listData", () => [])//商圈列表
  158. const typeList = useState("typeList", () => [])//商圈分类
  159. const topicType = () => {
  160. axios.post('/chat/topicType').then(response => {
  161. console.log(111222333)
  162. console.log(response.data);
  163. // console.log(1);
  164. typeList.value = response.data;
  165. })
  166. }
  167. const topicStatus = () => {
  168. axios.post('chat/topicStatus').then(response => {
  169. console.log(response);
  170. })
  171. }
  172. onMounted(() => {
  173. getTopicInfo(); //商圈信息
  174. getTopicReply(); //回复商圈列表
  175. topicType();
  176. topicStatus();
  177. })
  178. //加入群聊
  179. const joinGroup = () => {
  180. ElMessageBox.confirm(
  181. '加入群聊后,页面跳转至后台群聊页面',
  182. '是否加入群聊?',
  183. {
  184. confirmButtonText: '是',
  185. cancelButtonText: '否',
  186. center: true,
  187. }
  188. ).then(() => {
  189. console.log('groupId.value', groupId.value);
  190. let data = new FormData()
  191. data.append('group_id', groupId.value)
  192. axios.post('chat/joinGroup', data).then(res => {
  193. console.log('加入群聊 ', res);
  194. if (res.code == 0 && res.message !== '已加入群') {
  195. ElMessage.error(res.message)
  196. } else if (res.code == 0 && res.message == '已加入群') {
  197. ElMessage({
  198. message: res.message,
  199. type: 'success',
  200. })
  201. setTimeout(() => {
  202. // window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  203. window.open($BwebUrl + '/#/businessDistrict?userurl=' + $webUrl, '_blank');
  204. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  205. }, 1000)
  206. } else if (res.code == 200) {
  207. ElMessage({
  208. message: '加入成功',
  209. type: 'success',
  210. })
  211. setTimeout(() => {
  212. // window.open($BwebUrl + '/#/hall?userurl=' + $webUrl, '_blank');
  213. window.open($BwebUrl + '/#/businessDistrict?userurl=' + $webUrl, '_blank');
  214. //window.open('http://admindev.bjzxtw.org.cn/#/hall', '_blank');
  215. }, 1000)
  216. }
  217. })
  218. }).catch(() => {
  219. ElMessage({
  220. type: 'error',
  221. message: '已取消',
  222. })
  223. })
  224. }
  225. // 回复商圈
  226. const addReply = () => {
  227. let data = new FormData()
  228. data.append('id', id)
  229. data.append('content', content.value)
  230. axios.post('chat/addReply', data).then(res => {
  231. console.log('回复商圈 ', res);
  232. if (res.code == 0) {
  233. ElMessage.error(res.message)
  234. getTopicReply();
  235. } else if (res.code == 200) {
  236. ElMessage({
  237. message: '回复成功',
  238. type: 'success',
  239. })
  240. content.value = ''
  241. getTopicReply();
  242. }
  243. })
  244. }
  245. //3.获取商圈详情 end ---------------------------------------->
  246. //seo
  247. useSeoMeta({
  248. title: "商圈" + "_" + "三农资讯网_全国政务信息一体化应用平台",
  249. meta: [
  250. { name: 'description', content: "三农资讯网以服务于党和国家各级职能部门三农政务资讯发布及政务公开信息公示为基点,为全国县级以上各级党政机关及其职能部门配置各自公开独立网络发布平台。主要频道有:三农政务资讯,农科资讯,农资购销,农产购销,农贸资讯,三农致富信息,农村文化生活,三农政策法规,三农之窗,三农调查,三农服务,三农知识,农民工,打假维权等。三农资讯网打造最具影响力的三农信息发布平台,并成为最具权威的三农资讯网。_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 },
  251. { name: 'keywords', content: "三农资讯,农业,三农,三农在线,农业新闻,三农资讯网_三农资讯网-测试专用_全国政务信息一体化应用平台", tagPriority: 10 }
  252. ]
  253. });
  254. </script>
  255. <style lang="less" scoped>
  256. .topicInfoBox {
  257. .inner {
  258. width: 1200px;
  259. margin: 0 auto;
  260. //信息头部
  261. .infoHead {
  262. height: 200px;
  263. padding: 65px 0 60px 40px;
  264. border-bottom: 1px solid rgba(0, 0, 0, 0.10);
  265. box-sizing: border-box;
  266. >.left {
  267. .userInfo {
  268. margin-right: 90px;
  269. .item {
  270. margin-top: -5px;
  271. margin-right: -5px;
  272. :deep(.el-badge__content.is-fixed) {
  273. position: absolute;
  274. right: calc(1px + var(--el-badge-size) / 2);
  275. top: 0;
  276. transform: translateY(-31%) translateX(79%);
  277. z-index: var(--el-index-normal);
  278. }
  279. img {
  280. width: 66px;
  281. height: 66px;
  282. vertical-align: middle;
  283. border-radius: 50%;
  284. }
  285. }
  286. span {
  287. margin-left: 15px;
  288. font-family: Microsoft YaHei, Microsoft YaHei;
  289. font-weight: 400;
  290. font-size: 18px;
  291. color: #333333;
  292. }
  293. }
  294. .headContent {
  295. h2 {
  296. width: 750px;
  297. height: 56px;
  298. line-height: 28px;
  299. display: -webkit-box;
  300. -webkit-box-orient: vertical;
  301. -webkit-line-clamp: 2;
  302. overflow: hidden;
  303. text-overflow: ellipsis;
  304. word-break: break-all;
  305. font-family: Microsoft YaHei, Microsoft YaHei;
  306. font-weight: bold;
  307. font-size: 20px;
  308. color: #333333;
  309. margin-bottom: 26px;
  310. }
  311. >p {
  312. font-family: Microsoft YaHei, Microsoft YaHei;
  313. font-weight: 400;
  314. font-size: 16px;
  315. color: #333333;
  316. button {
  317. width: 86px;
  318. height: 32px;
  319. background-color: #028e21;
  320. color: #fff;
  321. border: none;
  322. margin-left: 100px;
  323. }
  324. }
  325. }
  326. }
  327. >.right {
  328. position: relative;
  329. div {
  330. position: absolute;
  331. right: 0;
  332. top: 0;
  333. width: 71px;
  334. height: 32px;
  335. line-height: 32px;
  336. text-align: center;
  337. background-color: #d9f0d6;
  338. margin-bottom: 29px;
  339. font-family: Microsoft YaHei, Microsoft YaHei;
  340. font-weight: 400;
  341. font-size: 16px;
  342. color: #33B023;
  343. }
  344. .one {
  345. color: #FFAA33;
  346. background-color: #fbebd5;
  347. }
  348. .two {
  349. color: #33B023;
  350. background-color: #d5ecd2;
  351. }
  352. .three {
  353. color: #666;
  354. background-color: #ebebeb;
  355. }
  356. p {
  357. width: 150px;
  358. text-align: right;
  359. position: absolute;
  360. top: 62px;
  361. right: 0;
  362. }
  363. }
  364. }
  365. // 有详情信息
  366. .infoContent {
  367. width: 1196px;
  368. overflow: hidden;
  369. padding: 30px 46px;
  370. font-family: Microsoft YaHei, Microsoft YaHei;
  371. font-size: 20px;
  372. line-height: 40px;
  373. box-sizing: border-box;
  374. div {
  375. word-wrap: break-word;
  376. /* 强制长单词或 URL 换行 */
  377. overflow-wrap: break-word;
  378. /* 现代推荐用法,等同于 word-wrap */
  379. white-space: pre-wrap;
  380. /* 保留空白字符并允许自动换行 */
  381. word-break: break-all;
  382. /* 强制在任意字符处换行 */
  383. }
  384. }
  385. .leftBottom::v-deep p {
  386. width: 1200px;
  387. white-space: pre-wrap;
  388. }
  389. //没有详情信息
  390. .comment_empty,
  391. .infoContent1 {
  392. height: 300px;
  393. line-height: 260px;
  394. text-align: center;
  395. img {
  396. width: 78px;
  397. height: 78px;
  398. vertical-align: -25px;
  399. vertical-align: middle;
  400. margin-right: 20px;
  401. }
  402. span {
  403. font-family: Microsoft YaHei, Microsoft YaHei;
  404. font-weight: bold;
  405. font-size: 26px;
  406. color: #CCCCCC;
  407. }
  408. }
  409. //评论
  410. .comment {
  411. h3 {
  412. height: 100px;
  413. padding-top: 30px;
  414. box-sizing: border-box;
  415. border-bottom: 1px solid #E1E1E1;
  416. font-family: Microsoft YaHei, Microsoft YaHei;
  417. font-weight: 400;
  418. font-size: 22px;
  419. color: #000000;
  420. }
  421. .commentList {
  422. border: 1px solid #E1E1E1;
  423. background-color: #fafafa;
  424. margin-top: 20px;
  425. padding: 30px 30px;
  426. box-sizing: border-box;
  427. display: flex;
  428. align-items: flex-start;
  429. justify-content: space-between;
  430. .left {
  431. width: 400px;
  432. margin-right: 30px;
  433. display: flex;
  434. justify-content: space-between;
  435. img {
  436. width: 52px;
  437. height: 52px;
  438. border-radius: 50%;
  439. vertical-align: middle;
  440. margin-right: 15px;
  441. }
  442. span {
  443. height: 52px;
  444. line-height: 22px;
  445. padding-top: 10px;
  446. }
  447. .name {
  448. width: 120px;
  449. font-family: Microsoft YaHei, Microsoft YaHei;
  450. font-weight: 400;
  451. font-size: 16px;
  452. color: #333333;
  453. margin-right: 15px;
  454. white-space: nowrap;
  455. overflow: hidden;
  456. text-overflow: ellipsis;
  457. display: block;
  458. }
  459. }
  460. .center {
  461. .context {
  462. width: 700px;
  463. margin-right: 40px;
  464. display: -webkit-box;
  465. -webkit-box-orient: vertical;
  466. -webkit-line-clamp: 2;
  467. overflow: hidden;
  468. text-overflow: ellipsis;
  469. word-break: break-all;
  470. font-family: Microsoft YaHei, Microsoft YaHei;
  471. font-weight: bold;
  472. font-size: 16px;
  473. color: #333333;
  474. }
  475. }
  476. .right {
  477. .time {
  478. display: block;
  479. width: 200px;
  480. font-family: Microsoft YaHei, Microsoft YaHei;
  481. font-weight: 400;
  482. font-size: 16px;
  483. color: #999999;
  484. margin-right: 30px;
  485. }
  486. span {
  487. font-family: Microsoft YaHei, Microsoft YaHei;
  488. font-weight: 400;
  489. font-size: 16px;
  490. color: #333333;
  491. }
  492. }
  493. }
  494. }
  495. }
  496. }
  497. //评论回复
  498. .message {
  499. width: 1200px;
  500. margin: 0 auto 20px;
  501. padding: 0px 25px;
  502. box-sizing: border-box;
  503. height: 145px;
  504. line-height: 145px;
  505. background-color: #ecf5ee;
  506. .inner {
  507. .messageInput {
  508. width: 1000px;
  509. height: 67px;
  510. outline: none;
  511. border: 1px solid #E1E1E1;
  512. background-color: #fafafa;
  513. font-family: Microsoft YaHei, Microsoft YaHei;
  514. font-weight: 400;
  515. font-size: 18px;
  516. color: #666;
  517. padding: 0 20px;
  518. box-sizing: border-box;
  519. }
  520. .btn {
  521. width: 115px;
  522. height: 40px;
  523. border: none;
  524. background-color: #028e21;
  525. color: #fff;
  526. border-radius: 6px;
  527. margin-left: 36px;
  528. font-family: Microsoft YaHei, Microsoft YaHei;
  529. font-weight: 400;
  530. font-size: 16px;
  531. }
  532. }
  533. }
  534. //分页
  535. .paginationBox {
  536. display: flex;
  537. justify-content: center;
  538. margin-top: 60px;
  539. margin-bottom: 90px;
  540. // 鼠标移入后字体颜色
  541. :deep(.el-pagination:hover) {
  542. color: #139609;
  543. }
  544. :deep(.el-pagination.is-background .btn-next),
  545. :deep(.el-pagination.is-background .btn-prev) {
  546. width: 70px;
  547. height: 34px;
  548. margin: 0px 10px;
  549. border-radius: 4px;
  550. }
  551. :deep(.el-pagination.is-background .el-pager li) {
  552. margin: 0px 10px;
  553. width: 38px;
  554. height: 34px;
  555. border-radius: 4px;
  556. }
  557. :deep(.el-pagination.is-background .btn-next.is-active),
  558. :deep(.el-pagination.is-background .btn-prev.is-active),
  559. :deep(.el-pagination.is-background .el-pager li.is-active) {
  560. background-color: #028e21;
  561. color: #fff;
  562. }
  563. }
  564. </style>